<template>
  <div class="toast-container">
    <div class="again" v-if="status == 1 ">
      <img :src="totalPic.again" alt>
      <div class="play-again" @click="playAgain"></div>
    </div>

    <div class="svip" v-else-if="status == 2">
      <img style="width:90%;" :src="totalPic.svip" alt>
    </div>

    <div class="award-status" v-else-if="status == 3">
      <img :src="totalPic.awardStatus" alt>
    </div>

    <!-- 通过成功，获得奖券 -->
    <div class="win-it" v-else-if="status == 4">
      <img :src="totalPic.win" alt>

      <div class="to-win">{{ finishGameTime }}秒通关</div>
      <div class="invite-friends" @click="inviteFreind"></div>
    </div>

    <!-- 未获得苹果弹窗 -->
    <div class="iphone-toast" v-else-if="status == 5">
      <img :src="totalPic.pic10" alt>
      <!-- <div class="invite-friends" @click="inviteFreind"></div> -->
    </div>

    <div class="clost-btn" @click="closeToast(status)">
      <img :src="totalPic.x" alt>
    </div>
  </div>
</template>
<script>
import { filterPic } from "../apis/utils.js";
export default {
  props: {
    status: {
      type: Number,
      default: 0
    },
    finishGameTime: Number,
    onClose: Function
  },

  created() {
    const imgUrl = {
      again: "again.png",
      svip: "svip.png",
      awardStatus: "award-status.png",
      x: "x.png",
      win: "win.png",
      pic10: "10.png"
    };
    this.totalPic = filterPic(imgUrl);
  },

  methods: {
    closeToast(e) {
      if (e == 1 || e == 2 || e == 5) {
        this.onClose(e);
      } else {
        this.onClose(0);
      }
    },

    // 再来一次
    playAgain() {
      this.onClose(1);
    },

    inviteFreind() {
      share('周年庆', '周年庆活动，邀请朋友一起赢iPhone', '');
      console.log("邀请朋友");
    }
  }
};
</script>
<style lang="less" scoped>
.toast-container {
  position: fixed;
  z-index: 555;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  .svip {
    position: absolute;
    top: 2rem;
    text-align: center;
  }
  .again {
    position: absolute;
    top: 2rem;
    text-align: center;
    img {
      width: 90%;
    }
  }

  .play-again {
    position: absolute;
    top: 6rem;
    left: 0;
    right: 0;
    width: 4.2rem;
    height: 0.8rem;
    margin: 0 auto;
  }

  .award-status {
    position: absolute;
    top: 1.5rem;
    left: 0;
    right: 0;
    width: 80%;
    margin: auto;
  }
  .win-it {
    position: absolute;
    top: 2.2rem;
    left: 0;
    right: 0;
    width: 80%;
    margin: auto;
  }
  .invite-friends {
    position: absolute;
    top: 6.7rem;
    left: 0;
    right: 0;
    width: 80%;
    margin: auto;
    width: 3.7rem;
    height: 1rem;
  }

  .clost-btn {
    position: absolute;
    top: 1.7rem;
    right: 0.8rem;
    width: 1rem;
    height: 18rem;
  }

  .iphone-toast {
    position: absolute;
    top: 1.5rem;
  }
}

.to-win {
  position: absolute;
  bottom: 1.65rem;
  left: 1.7rem;
  font-size: .5rem;
  color: #fff;
}
</style>


